<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            list-style: none;
        }

        body {
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            background-color: rgb(250, 220, 250);
            transition: 1s;
        }

        .shell {
            width: 280px;
            height: 400px;
            background-color: #fff;
            box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.4);
            display: flex;
            flex-direction: column;

        }

        .shell-top {
            width: 100%;
            height: 340px;
            border-bottom: 1px solid rgba(223, 223, 223);
            overflow-x: hidden;
        }

        .shell-top ul {
            width: 300%;
            height: 100%;
            display: flex;
            position: relative;
            transition: .3s;
            left: 0;
        }

        .shell-top ul li {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-evenly;
        }

        .shell-top ul li img {
            width: 150px;
        }

        .shell-top ul li .box-one {
            width: 70%;
            height: 10px;
            border-radius: 10px;
            background-color: rgb(220, 220, 220);
        }

        .shell-top ul li .box-two {
            width: 50%;
            height: 10px;
            border-radius: 10px;
            background-color: rgb(220, 220, 220);
        }

        .shell-bottom {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-evenly;
            height: 58px;
        }

        .shell-bottom li {
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            filter: grayscale(0.5)
        }

        .shell-bottom li img {
            width: 40px;
        }
    </style>
</head>

<body>
    <div class="shell">
        <div class="shell-top">
            <ul class="main">
                <li>
                    <img src="./1.png">
                    <div class="box-one"></div>
                    <div class="box-two"></div>
                    <div class="box-one"></div>
                </li>
                <li>
                    <img src="./2.png">
                    <div class="box-one"></div>
                    <div class="box-two"></div>
                    <div class="box-one"></div>
                </li>
                <li>
                    <img src="./3.png">
                    <div class="box-one"></div>
                    <div class="box-two"></div>
                    <div class="box-one"></div>
                </li>
            </ul>

        </div>
        <ul class="shell-bottom">
            <li class="list"><img src="./1.png"></li>
            <li class="list"><img src="./2.png"></li>
            <li class="list"><img src="./3.png"></li>
        </ul>
    </div>
    <script>
        let list = document.querySelectorAll(".list")
        let main = document.querySelector(".main")
        for (let i = 0; i < list.length; i++) {
            list[i].addEventListener("click", () => {
                main.style.left = (i * -100) + "%"
                // 点击第一个的时候i是0，又因为在if判断里面0为false,所以当i为1或2的时候触发背景渐变
                // 再在判断里加一层三目表达式，分别判断i等等于1和i等等于2时的背景色
                if (i) {
                    i == 1 ? document.body.style.backgroundColor = "rgb(240, 175, 195)" : document.body.style.backgroundColor = "rgb(180, 200, 150)"
                } else {
                    // 如果都不满足就说明i是0了，i是0时变回原来的背景色
                    document.body.style.backgroundColor = "rgb(250, 220, 250)"
                }
            })
        }
    </script>
</body>

</html>